import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from 'vuex-persistedstate'
Vue.use(Vuex)
export default new Vuex.Store({
    state: {
        isCollapse: false,
        asideActive: "概览"
    },
    mutations: {
        collapseMenu(state) {
            state.isCollapse = !state.isCollapse
        },
        updateAsideActive(state, val) {
            state.asideActive = val;
        }
    },
    plugins: [
        persistedState({
            //默认使用localStorage来固化数据，也可使用sessionStorage，配置一样
            storage: window.localStorage,
            reducer(val) {
                return {
                    isCollapse: val.isCollapse,
                    asideActive: val.asideActive
                }
            }
        })
    ]
})